cin=lambda:list(map(int,input().split()))
n,k=cin()
A=cin()
C=[0 for i in range(n+1)]
while True:
if A[0]>A[1]:
A[0],A[1]=A[1],A[0]
A=A[1:]+A[:1]
C[A[0]]+=1
if A[0]==n or C[A[0]]>=k:
print(A[0])
break
#include<bits/stdc++.h>
#define ll unsigned long long
#define endl '\n'
using namespace std;
int main()
{
ll n,k;
cin>>n>>k;
ll a[n];
cin>>a[0];
ll max1=a[0];
for(int i=1;i<n;i++)
{
cin>>a[i];
if(a[i]>max1)
max1=a[i];
}
if(k>=n-1)
cout<<max1<<endl;
else
{
int s=a[0],win=0;
for (int i = 1; i < n && win < k; i++)
{
if (a[i] > s)
{
s = a[i];
win = 1;
}
else
{
win++;
}
}
cout<<s<<endl;
}
}
732A - Buy a Shovel | 1220C - Substring Game in the Lesson |
452A - Eevee | 1647B - Madoka and the Elegant Gift |
1408A - Circle Coloring | 766B - Mahmoud and a Triangle |
1618C - Paint the Array | 469A - I Wanna Be the Guy |
1294A - Collecting Coins | 1227A - Math Problem |
349A - Cinema Line | 47A - Triangular numbers |
1516B - AGAGA XOOORRR | 1515A - Phoenix and Gold |
1515B - Phoenix and Puzzle | 155A - I_love_username |
49A - Sleuth | 1541A - Pretty Permutations |
1632C - Strange Test | 673A - Bear and Game |
276A - Lunch Rush | 1205A - Almost Equal |
1020B - Badge | 1353A - Most Unstable Array |
770A - New Password | 1646B - Quality vs Quantity |
80A - Panoramix's Prediction | 1354B - Ternary String |
122B - Lucky Substring | 266B - Queue at the School |